package com.lagou.client.View;

import com.lagou.client.ClientIntiClose;
import com.lagou.client.ClientScanner;
import com.lagou.model.Message;

import java.io.IOException;

/**
 * 编程实现客户端的主界面和相应功能的实现
 */
public class ClientView {

    /**
     * 为了可以使用输入输出流，采用合成复用原则
     */
    private ClientIntiClose cic;
    private ClientManagerView cmv;
    private ClientUserView cuv;

    public ClientView (ClientIntiClose cic){
        this.cic = cic;
    }
    /**
     * 自定义成员方法实现客户端主界面的绘制
     */
    public void clientMainPage() throws IOException, ClassNotFoundException {
        while (true) {
            System.out.println(" \n\n\t\t   在线考试系统");
            System.out.println("------------------------------------");
            System.out.println("   [1] 学员系统");
            System.out.println("   [2] 管理员系统");
            System.out.println("   [0] 退出系统");
            System.out.println("------------------------------------");
            System.out.println("请选择要进行的业务编号：");
            int choose = ClientScanner.getSc().nextInt();
            switch (choose) {
                case 1:
                    cuv = new ClientUserView(cic);
                    cuv.clientUserLogin();
                    break;
                case 2:
                    cmv = new ClientManagerView(cic);
                    cmv.clientManagerLogin();
                    break;
                case 0:
                    System.out.println("正在退出系统...");
                    Message message = new Message("Quit");
                    //2.将UserMessage类型的对象通过对象输出流发送给服务器
                    cic.getOos().writeObject(message);
                    return;
                default:
                    System.out.println("输入错误，请重新选择！");
            }
        }
    }








}
